package com.wb3.organizer.action;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.wb3.organizer.model.Account;
import com.wb3.organizer.model.Appointment;
import com.wb3.organizer.model.Task;
import com.wb3.organizer.service.AppointmentService;
import com.wb3.organizer.service.TaskService;

public class DayAtAGlanceAction extends ActionSupport implements SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Map<String, Object> session;

	private List<Task> tasks;

	private List<Appointment> appointments;
	
	private TaskService taskService;
	
	private AppointmentService appointmentService;

	public void setSession(Map<String, Object> inSession) {
		this.session = inSession;
	}

	public List<Task> getTasks() {
		return tasks;
	}

	public void setTasks(List<Task> tasks) {
		this.tasks = tasks;
	}

	public List<Appointment> getAppointments() {
		return appointments;
	}

	public void setAppointments(List<Appointment> appointments) {
		this.appointments = appointments;
	}

	public TaskService getTaskService() {
		return taskService;
	}

	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

	public AppointmentService getAppointmentService() {
		return appointmentService;
	}

	public void setAppointmentService(AppointmentService appointmentService) {
		this.appointmentService = appointmentService;
	}

	
	@Override
	public String execute() throws Exception {
		Account account = (Account) session.get("account");
		tasks = taskService.getTaskByTime(account, true);
		appointments = appointmentService.getAppointmentByTime(account, new Date(), "day");
		return SUCCESS;
	}
	

}
